package com.ruoyi.report_sdj.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import com.ruoyi.report_tg.domain.vo.TgsybgBsInfoVo;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.report_sdj.domain.vo.SdjMglblbgBsInfoVo;
import com.ruoyi.report_sdj.domain.bo.SdjMglblbgBsInfoBo;
import com.ruoyi.report_sdj.service.ISdjMglblbgBsInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 锚杆拉拔力试验检测报告
 *
 * @author zyb
 * @date 2024-07-23
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/report_sdj/sdjMglblbgBsInfo")
public class SdjMglblbgBsInfoController extends BaseController {

    private final ISdjMglblbgBsInfoService iSdjMglblbgBsInfoService;

    /**
     * 查询锚杆拉拔力试验检测报告列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<SdjMglblbgBsInfoVo> list(SdjMglblbgBsInfoBo bo, PageQuery pageQuery) {
        return iSdjMglblbgBsInfoService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出锚杆拉拔力试验检测报告列表
     */
    @SaCheckLogin
    @Log(title = "锚杆拉拔力试验检测报告 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(SdjMglblbgBsInfoBo bo, HttpServletResponse response) {
        List<SdjMglblbgBsInfoVo> list = iSdjMglblbgBsInfoService.queryList(bo);
        ExcelUtil.exportExcel(list, "锚杆拉拔力试验检测报告 ", SdjMglblbgBsInfoVo.class, response);
    }

    /**
     * 获取锚杆拉拔力试验检测报告详细信息
     *
     * @param excelId 主键
     */
    @SaCheckLogin
    @GetMapping("/{excelId}")
    public R<SdjMglblbgBsInfoVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long excelId) {
        return R.ok(iSdjMglblbgBsInfoService.queryById(excelId));
    }

    /**
     * 新增锚杆拉拔力试验检测报告
     */
    @SaCheckLogin
    @Log(title = "锚杆拉拔力试验检测报告 ", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody SdjMglblbgBsInfoBo bo) {
        return toAjax(iSdjMglblbgBsInfoService.insertByBo(bo));
    }

    /**
     * 修改锚杆拉拔力试验检测报告
     */
    @SaCheckLogin
    @Log(title = "锚杆拉拔力试验检测报告 ", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SdjMglblbgBsInfoBo bo) {
        return toAjax(iSdjMglblbgBsInfoService.updateByBo(bo));
    }

    /**
     * 删除锚杆拉拔力试验检测报告
     *
     * @param excelIds 主键串
     */
    @SaCheckLogin
    @Log(title = "锚杆拉拔力试验检测报告 ", businessType = BusinessType.DELETE)
    @DeleteMapping("/{excelIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] excelIds) {
        return toAjax(iSdjMglblbgBsInfoService.deleteWithValidByIds(Arrays.asList(excelIds), true));
    }

    /**
     * 生成 锚杆拉拔力试验 报告 检测结论
     */
    @SaCheckLogin
    @Log(title = "生成 锚杆拉拔力试验 报告 检测结论", businessType = BusinessType.OTHER)
    @PutMapping("/jcjl")
    public R<SdjMglblbgBsInfoVo> jcjl(@RequestBody SdjMglblbgBsInfoVo vo) {
        return R.ok(iSdjMglblbgBsInfoService.jcjl(vo));
    }
}
